
// 处理与hcl都有关的物质函数
exports.dataTransform = function (raw_data) {

    let [nodes, links, data] = [[], [], []]
    // HCl 当前查找物质
    let searchObj = raw_data.records[0]['_fields'][1]['properties']
    searchObj.id = 0

    // 处理nodes=[{},{}...]
    nodes[0] = searchObj
    raw_data.records.forEach((element, index) => {
        let otherObj = element['_fields'][0]['properties']
        otherObj.id = index + 1
        nodes.push(otherObj)
    })

    // 处理links=[{},{}...]
    for (let i = 0, length = nodes.length; i < length - 1; i++) {
        let linkObj = {
            "source": 0,
            "label": "couple"
        }
        linkObj['target'] = i + 1
        links.push(linkObj)
    }

    data = { nodes, links }
    return data

}
